package com.wno704.system.config;

import com.wno704.intf.config.WnoConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootVersion;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.SpringVersion;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description: 配置类
 * @Author: wno704
 * @Date: 2023/11/25
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

	@Autowired
	WnoConfig wnoConfig;

	@Bean
	@Profile("dev")
	public Runnable dev() {
		System.out.println("\n********************************************");
		System.out.println("\t\t\t\t开发环境");
		System.out.println("数据库类型\t\t\t：\t" +  wnoConfig.getIntfDB());
		System.out.println("日志目录\t\t\t\t：\t" +  wnoConfig.getLogDir());
		System.out.println("框架版本\t\t\t\t：\t" +  wnoConfig.getVersion());
		System.out.println("JDK版本\t\t\t\t：\t" +  System.getProperty("java.version"));
		System.out.println("内核版本\t\t\t\t：\t" +  System.getProperties().getProperty("os.arch"));
		System.out.println("系统版本\t\t\t\t：\t" +  System.getProperty("os.name"));
		System.out.println("Spring version\t\t: \t" + SpringVersion.getVersion());
		System.out.println("SpringBoot version\t: \t" + SpringBootVersion.getVersion());
		System.out.println("********************************************");
		return () -> {
		};
	}

	@Bean
	@Profile("test")
	public Runnable test() {
		System.out.println("\n********************************************");
		System.out.println("\t\t\t\t测试环境");
		System.out.println("数据库类型\t\t\t：\t" +  wnoConfig.getIntfDB());
		System.out.println("日志目录\t\t\t\t：\t" +  wnoConfig.getLogDir());
		System.out.println("框架版本\t\t\t\t：\t" +  wnoConfig.getVersion());
		System.out.println("JDK版本\t\t\t\t：\t" +  System.getProperty("java.version"));
		System.out.println("内核版本\t\t\t\t：\t" +  System.getProperties().getProperty("os.arch"));
		System.out.println("系统版本\t\t\t\t：\t" +  System.getProperty("os.name"));
		System.out.println("Spring version\t\t: \t" + SpringVersion.getVersion());
		System.out.println("SpringBoot version\t: \t" + SpringBootVersion.getVersion());
		System.out.println("********************************************");
		return () -> {
		};
	}

	@Bean
	@Profile("prod")
	public Runnable prod() {
		System.out.println("\n********************************************");
		System.out.println("\t\t生产环境");
		System.out.println("数据库类型\t\t\t：\t" +  wnoConfig.getIntfDB());
		System.out.println("日志目录\t\t\t：\t" +  wnoConfig.getLogDir());
		System.out.println("框架版本\t\t\t：\t" +  wnoConfig.getVersion());
		System.out.println("JDK版本\t\t\t\t：\t" +  System.getProperty("java.version"));
		System.out.println("内核版本\t\t\t：\t" +  System.getProperties().getProperty("os.arch"));
		System.out.println("系统版本\t\t\t：\t" +  System.getProperty("os.name"));
		System.out.println("Spring version\t\t\t: \t" + SpringVersion.getVersion());
		System.out.println("SpringBoot version\t\t: \t" + SpringBootVersion.getVersion());
		System.out.println("********************************************");
		return () -> {
		};
	}

}
